package com.icinfo.cloud.provider.punish.ucase.casemain.service.impl;

import com.icinfo.cloud.provider.common.exception.BusinessException;
import com.icinfo.cloud.provider.punish.ucase.casemain.mapper.CaseMainInfoCommonMapper;
import com.icinfo.cloud.provider.punish.ucase.casemain.service.ICaseMainInfoCommonService;
import com.icinfo.framework.core.service.support.MyBatisServiceSupport;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 描述: 案件通用类操作 对应的Service接口.<br>
 *
 * @author framework generator
 * @date 2022年04月09日
 */
@Service
@Slf4j
public class CaseMainInfoCommonServiceImpl extends MyBatisServiceSupport implements ICaseMainInfoCommonService {

    @Autowired
    private CaseMainInfoCommonMapper caseMainInfoCommonMapper;

    /**
     * 【V1.0.0】描述：从某个表中中查询特定字段
     * @author tianrunjia
     * @date 2022-04-09
     * @param someDataColumn
     * @param caseId
     * @param someTable
     * @param whereCondition
     * @return
     */
    @Override
    public Map<String, Object> getCaseMainInfoSomeDataFromSomeTable(String someDataColumn, String caseId, String someTable, String whereCondition) {
        if(StringUtils.isEmpty(someDataColumn) || StringUtils.isEmpty(caseId) || StringUtils.isEmpty(someTable)){
            throw new BusinessException("查询字段 或 案件id 或 查询表 为空！");
        }
        Map<String ,String > queryMap = new HashMap<>();
        queryMap.put("someDataColumn",someDataColumn);
        queryMap.put("caseId",caseId);
        queryMap.put("someTable",someTable);
        queryMap.put("whereCondition",whereCondition);
        return caseMainInfoCommonMapper.selectCaseMainInfoSomeDataFromSomeTable(queryMap);
    }
}
